import { RouteRecordRaw } from "vue-router";
import userRole from "@/access/userRole";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginPage from "@/views/user/UserLoginPage.vue";
import UserRegisterPage from "@/views/user/UserRegisterPage.vue";
import BasicLayout from "@/layouts/BasicLayout.vue";
import AdminUserPage from "@/views/admin/AdminUserPage.vue";
import AdminAppPage from "@/views/admin/AdminAppPage.vue";
import AdminQuestionPage from "@/views/admin/AdminQuestionPage.vue";
import HomePage from "@/views/HomePage.vue";
import AppDetailPage from "@/views/app/AppDetailPage.vue";
import AddAppPage from "@/views/app/app/AddAppPage.vue";
import AddQuestionPage from "@/views/app/question/AddQuestionPage.vue";
import AddScoringResultPage from "@/views/app/scrolling/AddScoringResultPage.vue";
import DoQuestionPage from "@/views/app/question/DoQuestionPage.vue";
import AnswerResultPage from "@/views/app/question/AnswerResultPage.vue";
import MyAnswerPage from "@/views/app/question/MyAnswerPage.vue";
import AppStatisticPage from "@/views/statistic/AppStatisticPage.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "home",
    component: BasicLayout,
    children: [
      {
        path: "/",
        name: "主页",
        component: HomePage,
      },
      {
        path: "/admin/user",
        name: "用户管理",
        component: AdminUserPage,
        meta: {
          access: userRole.ADMIN,
        },
      },
      {
        path: "/admin/app",
        name: "应用管理",
        component: AdminAppPage,
        meta: {
          access: userRole.ADMIN,
        },
      },
      {
        path: "/admin/question",
        name: "题目管理",
        component: AdminQuestionPage,
        meta: {
          access: userRole.ADMIN,
        },
      },
      {
        path: "/app/detail/:id",
        name: "应用详情页",
        props: true,
        component: AppDetailPage,
        meta: {
          hideInMenu: true,
        },
      },
      {
        path: "/add/app",
        name: "创建应用",
        component: AddAppPage,
      },
      {
        path: "/add/app/:id",
        name: "修改应用",
        props: true,
        component: AddAppPage,
        meta: {
          hideInMenu: true,
        },
      },
      {
        path: "/add/question/:appId",
        name: "创建题目",
        component: AddQuestionPage,
        props: true,
        meta: {
          hideInMenu: true,
        },
      },
      {
        path: "/add/scoring_result/:appId",
        name: "创建评分",
        component: AddScoringResultPage,
        props: true,
        meta: {
          hideInMenu: true,
        },
      },
      {
        path: "/answer/do/:appId",
        name: "答题",
        component: DoQuestionPage,
        props: true,
        meta: {
          hideInMenu: true,
          access: userRole.USER,
        },
      },
      {
        path: "/answer/result/:id",
        name: "答题结果",
        component: AnswerResultPage,
        props: true,
        meta: {
          hideInMenu: true,
          access: userRole.USER,
        },
      },
      {
        path: "/answer/my",
        name: "我的答题",
        component: MyAnswerPage,
        meta: {
          access: userRole.USER,
        },
      },
      {
        path: "/app_statistic",
        name: "应用统计",
        component: AppStatisticPage,
        meta: {
          access: userRole.ADMIN,
        },
      },
    ],
  },
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginPage,
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterPage,
      },
    ],
    meta: {
      hideInMenu: true,
    },
  },
];
